mod window;

use adw::prelude::*;
use gtk::gdk::Display;
use gtk::{gio, glib, Application, CssProvider, StyleContext};
use window::MainWindow;

const APPID: &str = "org.marcux.prionote";



fn main() -> glib::ExitCode {
    gio::resources_register_include!("prionote.gresource")
	.expect("Failed to register resources");

    let app = adw::Application::builder()
	.application_id(APPID)
	.build();

    gtk::init().expect("Failed to init gtk");
    load_css();
    app.connect_activate(build_ui);

    app.run()
}


fn build_ui(app: &adw::Application) {
    let main_win = MainWindow::new(app);
    main_win.present();
}


fn load_css() {
    let provider = CssProvider::new();
    provider.load_from_resource("/org/marcux/prionote/css/style.css");

    StyleContext::add_provider_for_display(
	&Display::default().expect("Cold not connect to default display"),
	&provider,
	gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
    );
}
